package com.sinping.qh.query.records;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author zhangjin
 * @create 2018/5/31
 */
@Data
public class CheckRecoredsQuery implements QueryParams,Serializable {

    static Map<String, String> aliasMap = new HashMap<>();
    static Map<String, Operator> operatorMap = new HashMap<>();


    private String checkPlanId;


    private String checkStatus;

    private String checkUnitId;

    private String checkBuildingId;

    /**
     * 检查人
     */
    private String checkUserId;

    static {
        aliasMap.put("checkPlanId", "check_plan_id");

        aliasMap.put("checkStatus", "check_status");

        aliasMap.put("checkUnitId", "check_unit_id");

        aliasMap.put("checkBuildingId", "check_building_id");

        aliasMap.put("checkUserId","check_user._id");

        operatorMap.put("checkPlanId", Operator.eq);

        operatorMap.put("checkStatus", Operator.regex);

        operatorMap.put("checkUnitId", Operator.eq);

        operatorMap.put("checkBuildingId", Operator.eq);


        operatorMap.put("checkUserId",Operator.in);

    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }

}
